package com.cn.learn.httpclient.config;

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName HttpClientConfig
 * @Description http client的配置文件
 * @Author JiJiang
 * @Date 2023/5/20 15:39
 * @Version 1.0
 */
@Configuration
public class HttpClientConfig {


    @Bean
    public PoolingHttpClientConnectionManager httpClientConnectionManager() {
        //1.创建HttpClient连接管理器
        PoolingHttpClientConnectionManager poolManager = new PoolingHttpClientConnectionManager();
        //2.设置参数
        poolManager.setMaxTotal(200);//设置最大连接数
        poolManager.setDefaultMaxPerRoute(20);//设置每个主机的最大并发
        return poolManager;
    }


}
